// pages/userGraphic/userGraphic.js
import { proxy } from '../../utils/util.js';
import LoginStore from '../login/store.js';
const app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    navbarData: {
      showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
      title: '', //导航栏 中间的标题
      background: 'linear-gradient(to bottom, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0))',
      hasFilter: true,
      color: '#FFFFFF',
      btnStyle: 'white', //black, white
    },
    navBarHeight: app.globalData.height,
    params: {},
    urlStr: '',
    userId: '',
    curWorksType: 'graphicList'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      userId: options.userId
    })
    this.setTabs()
  },

  _tabclick: function (e) {
    let item = e.detail;

    let urlStr = `${proxy}/community/v2/user/graphic`;
    let params = {
      resourceType: '3',
      imgsize: 'p1,p2,p3',
      queriedUserId: this.data.userId,
      page: 1,
      size: 6,
      type: 'json'
    };

    this.setData({
      urlStr: urlStr,
      params: params,
      curWorksType: item.name
    })
  },

  setTabs: function () {
    let tabEl = this.selectComponent('#worksTabs')
    tabEl.setTabs([{
      displayName: '我发布的',
      name: 'graphicList'
    }], (item) => {
      this._tabclick({
        detail: {
          name: item.name
        }
      })
    })
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    let params = this.data.params;
    params.page++;
    this.setData({
      params: params
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})